/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.chart.AStoreDetails;
import com.thor.palmmall.spi.chart.SStoreDetails;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class AStoreDetailsConverter implements Converter<SStoreDetails, AStoreDetails> {

  public static AStoreDetailsConverter getInstance() {
    if (instance == null)
      instance = new AStoreDetailsConverter();
    return instance;
  }

  private static AStoreDetailsConverter instance;

  private AStoreDetailsConverter() {
  }

  @Override
  public AStoreDetails convert(SStoreDetails source) {
    if (source == null) {
      return null;
    }
    AStoreDetails target = new AStoreDetails();
    target.setCompLastCalcRate(source.getCompLastCalcRate());
    target.setSalePerArea(source.getSalePerArea());
    target.setSales(source.getSales());
    target.setSalesPerDay(source.getSalesPerDay());
    target.setUcn(UCN.newInstance(source.getUcn()));
    return target;
  }

}
